package com.softeem.springbootdemo2.controller;

import com.softeem.springbootdemo2.entity.User;
import com.softeem.springbootdemo2.scrvice.UserScrvice;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
@RestController
public class UserController {

    @Resource
    private UserScrvice userScrvice;

    @GetMapping("/user/list")
    public List<User> list(){
        return userScrvice.list();
    }

    @GetMapping("/user/add")
    public boolean add(User user){
        return userScrvice.save(user);
    }

    @GetMapping("/user/update")
    public boolean update(User user){
        return userScrvice.updateById(user);
    }

    @GetMapping("/user/{id}")
    public boolean del(@PathVariable Integer id){
        return userScrvice.removeById(id);
    }

}
